package com.lap.auth.application.menu.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import java.util.ArrayList;
import java.util.List;
import lombok.AccessLevel;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;

@Data
@Schema(description = "菜单树数据传输")
public class MenuNodeDto {

  @Schema(description = "菜单唯一标识")
  private Integer id;

  @Schema(description = "菜单父标识")
  private Integer pid;

  @Schema(description = "菜单树路径")
  private List<Integer> pidPaths;

  @Schema(description = "菜单类型")
  private Integer type;

  @Schema(description = "菜单请求路径")
  private String path;

  @Schema(description = "菜单名称")
  private String name;

  @Schema(description = "菜单组件")
  private String component;

  @Schema(description = "菜单跳转路径")
  private String redirect;

  @Schema(description = "菜单跳转路径")
  private String link;

  @Schema(description = "按钮权限码")
  private String permCode;

  @Schema(description = "菜单排序")
  private Integer sortOrder;

  @Schema(description = "菜单元件")
  private MetaDto meta;

  @Setter
  @Getter(AccessLevel.NONE)
  @Schema(description = "子菜单")
  private List<MenuNodeDto> children;

  public List<MenuNodeDto> getChildren() {
    if (children == null) {
      children = new ArrayList<>();
    }
    return children;
  }
}
